package com.tal.pad.orc.base.net;

/**
 * @author shixiaoqiang
 * 远程网络配置（配置中心,控制）
 */
public class AppNetWorkConfigRemoteInfo {

    public static final int MIN_TIME_OUT = 10;
    public static final int MAX_TIME_OUT = 200;


    /**
     * 可以使用备用IP方案
     */
    public boolean enableBackUpIp = false;
    /**
     * 失败次数，即可触发
     */
    public int failedCountLimit = 6;

    public long maxBackUpIpTime = 60000;

    public int connectTime = 10;
    /**
     * 读超时  单位 秒
     */
    public int readTimeout = 10;
    /**
     * 写超时  单位 秒
     */
    public int writeTimeout = 10;

    /**
     * 默认代理IP
     */
    public String defaultIP = "47.102.153.69";


    /**
     * 对超时 时间做一个保护 值在 10 -200 秒
     *
     * @return
     */
    public int getConnectTime() {
        if (connectTime >= MIN_TIME_OUT && connectTime <= MAX_TIME_OUT) {
            return connectTime;
        }

        return MIN_TIME_OUT;

    }


    public int getReadTimeout() {
        if (readTimeout >= MIN_TIME_OUT && readTimeout <= MAX_TIME_OUT) {
            return readTimeout;
        }

        return MIN_TIME_OUT;
    }

    public void setReadTimeout(int readTimeout) {
        this.readTimeout = readTimeout;
    }

    public int getWriteTimeout() {
        if (writeTimeout >= MIN_TIME_OUT && writeTimeout <= MAX_TIME_OUT) {
            return writeTimeout;
        }

        return MIN_TIME_OUT;
    }


}